package router

import (
	"IrisStandard/controller"
	"github.com/kataras/iris"
	"github.com/kataras/iris/mvc"
)

var basePath = "/api"

func InitRouter(app *iris.Application) {
	app.Use(CrossAccess)
	mvc.New(app.Party(basePath + "/auth")).Handle(controller.NewAuthController())
	mvc.New(app.Party(basePath + "/user", CheckLoginTokenMiddleware)).Handle(controller.NewUserController())
}

func CrossAccess(ctx iris.Context) {
	ctx.ResponseWriter().Header().Add("Access-Control-Allow-Origin", "*")
	ctx.Next()
}

